package com.itheima.api.integer;

public class Integer4Demo {
    public static void main(String[] args) {
        String s = "91 27 a 46 38 50";
        //分割字符串,获取数组对象
        String[] strArr = s.split(" ");
        //定义int类型数组对象,转载运算结果
        int[] numArr = new int[strArr.length];
        //遍历数组,用parseInt方法依次转换成int类型数据并装入numArr对象
        for (int i = 0; i < numArr.length; i++) {
            //numArr[i] instanceof int
            try{
                numArr[i] = Integer.parseInt(strArr[i]);
            }catch (Exception e){
                System.out.println(i + "索引位置的" + strArr[i] + "不是一个数字");

            }
        }

        for (int i = 0; i < numArr.length; i++) {
            System.out.println(numArr[i]);
        }
    }
}
